package com.njtoyo.taxi.admin.mapper.master.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.njtoyo.taxi.admin.mapper.master.enums.ActivitySeckillRuleRoundUnit;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author Dell
 * @since 2021-07-01
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "ActivitySeckillRule对象", description = "")
public class ActivitySeckillRule implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "活动ID")
    private Long activityId;

    @ApiModelProperty(value = "区域编号")
    private Long regionId;

    @ApiModelProperty(value = "是否覆盖全国")
    private Boolean isCoverAllRegions;

    @ApiModelProperty(value = "每轮类型")
    private ActivitySeckillRuleRoundUnit roundUnit;

    @ApiModelProperty(value = "每轮开始数字，比如round_unit为周，数字为5，则为每周五开始的活动，若round_unit为小时或日，则为null")
    @TableField(updateStrategy = FieldStrategy.IGNORED, insertStrategy = FieldStrategy.IGNORED)
    private Long roundStartNumber;

    @ApiModelProperty(value = "每轮结束数字，比如round_unit为周，数字为5，则为每周五结束的活动，若round_unit为小时或日，则为null")
    @TableField(updateStrategy = FieldStrategy.IGNORED, insertStrategy = FieldStrategy.IGNORED)
    private Long roundEndNumber;

    @ApiModelProperty(value = "每轮开始的时间，如00：00：00")
    private Date roundStartTime;

    @ApiModelProperty(value = "每轮结束的时间，如23：59：59")
    private Date roundEndTime;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    private Date createdAt;

    @ApiModelProperty(value = "修改时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updatedAt;

    public String getRoundStartTime() {
        SimpleDateFormat roundSdf = new SimpleDateFormat("HH:mm:ss");

        return roundSdf.format(this.roundStartTime);
    }

    public String getRoundEndTime() {
        SimpleDateFormat roundSdf = new SimpleDateFormat("HH:mm:ss");

        return roundSdf.format(this.roundEndTime);
    }
}
